//
//  BeasCollectionViewDataSource.m
//  iNCardNew
//
//  Created by Ourpower on 2014/12/4.
//  Copyright (c) 2014年 Ourpower. All rights reserved.
//

#import "BeasCollectionViewDataSource.h"

@implementation BeasCollectionViewDataSource

- (id)initWithItems:(NSArray *) items  cellIdentifier: (NSString *)cellIdentifier configureCellBlock: (CollectionViewCellConfigureBlock)configureCellBlock{
    self = [super init];
    if (self) {
        [self setItems: items];
        [self setCellIdentifier: cellIdentifier];
        [self setConfigureCellBlock: configureCellBlock];
    }
    return self;
}

- (id)itemAtIndexPath:(NSIndexPath *)indexPath {
    return _items[(NSUInteger)indexPath.row];
}

#pragma mark CollectionViewDataSource
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _items.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier: _cellIdentifier forIndexPath: indexPath];
    id item     = [self itemAtIndexPath: indexPath];
    if (_configureCellBlock) {
        _configureCellBlock(cell, item );
    }
    return cell;
}
@end
